package com.yiyukongjian.house;

import java.util.List;
import java.util.Map;

import android.app.ListActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class QueryGeneralResultActivity extends ListActivity {

	@SuppressWarnings("unchecked")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Log.i("House", getIntent().getExtras().get(HouseConstants.KEY_RESULT).toString());
		List<Map<String,?>> content = (List<Map<String, ?>>) getIntent().getExtras().get(HouseConstants.KEY_RESULT);
		SimpleAdapter adapter = new SimpleAdapter(this,content, R.layout.query_general_item,
				new String[] {HouseConstants.KEY_FWDZ, HouseConstants.KEY_FZXM, HouseConstants.KEY_FZZJHM, HouseConstants.KEY_FZLXDH,
				HouseConstants.KEY_CZRXM,HouseConstants.KEY_CZRZJHM,HouseConstants.KEY_CZRLXDH,
				HouseConstants.KEY_QZRQ,HouseConstants.KEY_TZRQ,HouseConstants.KEY_DJRXM,HouseConstants.KEY_ID}, 
				new int[] {R.id.query_general_fwdz,R.id.query_general_fzxm,R.id.query_general_fzzjhm,R.id.query_general_fzdh,
				R.id.query_general_czrxm,R.id.query_general_czrzjhm,R.id.query_general_czrdh,
				R.id.query_general_qzrq,R.id.query_general_tzrq,R.id.query_general_djrxm,R.id.query_general_pk});

		this.getListView().setAdapter(adapter);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Log.i("House", "Click Item");
		TextView tv = (TextView) v.findViewById(R.id.query_general_pk);
		Log.i("House", "PK : " + tv.getText());
//		getListView().getItemAtPosition(position);
	}
}
